package SuanFa;

public class KuaiSu {
    public static void main(String[] args) {
        int[] arr = {10,7,2,4,7,62,3,4,2,1,8,9,19};
        getKuaiSu(arr,0,arr.length-1);
        for (int i:arr
             ) {
            System.out.println(i);
        }

    }


    public static int[] getKuaiSu(int[] array,int op,int ed){
        int i=op;
        int j=ed;
        if (i>j){
            return null;
        }
        int x=array[op];

        int t;

        while (i<j){
            while (array[j]>=x&&i<j){
                j-=1;
            }
            while (array[i]<=x&&i<j){
                i+=1;
            }

            if (i<j) {
                t = array[j];
                array[j] = array[i];
                array[i] = t;
            }

        }
        array[op]=array[i];
        array[i]=x;
        getKuaiSu(array,op,j-1);
        getKuaiSu(array,j+1,ed);
       return array;
    }
}
